#include "common.h"


int main()
{
    //打开管道
    int fd = open(FILE_NAME,O_WRONLY);
    if(fd < 0)
    {
        perror("open");
        return 1;
    }
    //写入数据
    char msg[128];
    while(1)
    {
        msg[0] = '\0';
        printf("Enter content: ");
        fflush(stdout);
        size_t size = read(0,msg,sizeof(msg) - 1);
        if(size > 0)
        {
            msg[size - 1] = '\0';
            //信息写入管道
            write(fd,msg,strlen(msg));
        }
    }
    close(fd);
    return 0;
}